package com.ruoyi.hkCamera.service;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.hkCamera.common.HCNetSDK;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

import static com.ruoyi.hkCamera.config.AlarmConfig.devUserId2IpMap;

/**
 * 相机 service类
 */
@Slf4j
@Service
public class CameraService {

    /**
     * 抓拍回调业务逻辑处理
     */
    public void captureCallBack(Map<String, Object> paramMap) {
        HCNetSDK.NET_ITS_PLATE_RESULT strItsPlateResult = (HCNetSDK.NET_ITS_PLATE_RESULT) paramMap.get("strItsPlateResult");
        int dwIndex = strItsPlateResult.struVehicleInfo.dwIndex; //抓拍序号
        int lUserID = MapUtil.getInt(paramMap, "lUserID");
        log.info("摄像机抓拍回调 dwIndex: " + dwIndex + " IP: " + devUserId2IpMap.get(lUserID));
    }

    public static void main(String[] args) {
        String checkTime = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
        String checkNo = StrUtil.subPre(checkTime, 13);
        System.out.println(checkTime);
        System.out.println(checkNo);
    }
}
